package com.scoy.honeymei.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.scoy.honeymei.adapter.tabadapter.OyAdapter;
import com.scoy.honeymei.bean.CatePlateBean;
import com.scoy.honeymei.bean.CinemaBean;
import com.scoy.honeymei.databinding.ItemCinamaListBinding;
import com.scoy.honeymei.databinding.ItemShopCtateBinding;
import com.scoy.honeymei.utils.GlideImgUtil;

import org.jetbrains.annotations.NotNull;

public class ShopCateCheckAdapter extends OyAdapter<CatePlateBean> {


    public ShopCateCheckAdapter(Context context) {
        super(context);
    }

    @NonNull
    @NotNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
        ItemShopCtateBinding binding = ItemShopCtateBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
        return new OyHolder(binding);
    }

    @Override
    public void onBindViewHolder(@NonNull @NotNull RecyclerView.ViewHolder holder, int position) {
        OyHolder mHolder = (OyHolder) holder;
        CatePlateBean mBean = datalist.get(position);
        GlideImgUtil.glidePic(context, mBean.getImage(), mHolder.binding.scIv);
        mHolder.binding.scNameTv.setText(mBean.getName());
        mHolder.binding.scNameTv.setSelected(mBean.getIscheck() == 1);
        mHolder.itemView.setOnClickListener(v -> {
            mBean.setIscheck(mHolder.binding.scNameTv.isSelected() ? 0 : 1);
            mHolder.binding.scNameTv.setSelected(!mHolder.binding.scNameTv.isSelected());
        });

    }

    static class OyHolder extends RecyclerView.ViewHolder {
        private ItemShopCtateBinding binding;

        public OyHolder(ItemShopCtateBinding binding) {
            super(binding.getRoot());
            this.binding = binding;
        }
    }

}
